# 1. 源文件列表
SRCS= led.c main.c startup.s
# 2. 目标文件
TARGET= led.bin
ELF= led.elf
# 3. 编译器
CC= arm-linux-gnueabihf-gcc
AS= arm-linux-gnueabihf-gcc
LD= arm-linux-gnueabihf-ld
OBJCOPY = arm-linux-gnueabihf-objcopy
# 4. 编译选项配置
CCFLAGS= -g -c -std=c99 -marm
ASFLAGS= -g -c -marm
LDFLAGS= -Ttext=0x87800000 -nostdlib
# 5. 目标规则
OBJS= startup.o led.o main.o

all:$(TARGET) led.dis

$(TARGET):$(ELF)
	$(OBJCOPY) -O binary $^ $@

$(ELF):$(OBJS)
	$(LD) $(LDFLAGS) -o $@ $^
led.o:led.c led.h
	$(CC) $(CCFLAGS) $< -o $@
main.o:main.c led.h
	$(CC) $(CCFLAGS) $< -o $@
startup.o:startup.s
	$(AS) $(ASFLAGS) $< -o $@
led.dis:led.elf
	arm-linux-gnueabihf-objdump -D -marm led.elf > led.dis
.PHONY:clean
clean:
	rm -f *.o *.elf *.bin *.imx *.dis






